<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('公司列表')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="role-form">
                <div class="select-list">
                    <ul>
                        <li>
                            姓名：<input type="text" name="name"/>
                        </li>
                        <li>
                            工号：<input type="text" name="badge"/>
                        </li>
                        <li>
                            在岗状态：<select name="empStatus">
                            <option value="0">全部</option>
                            <option value="1" selected = "selected">在岗</option>
                            <option value="2">离职</option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:role:export">
                <i class="fa fa-download"></i> 导出
            </a>
            <button type="button" onclick="details()" class="btn btn-primary btn-sm">查看详情</button>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="emp-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>


<script th:inline="javascript">
    var prefix = ctx + "neworgs";
    $(function () {
        queryUserList();
    });


    function queryUserList() {
        var options = {
            id: "emp-table",
            code: "eid",
            uniqueId: "eid",
            url: prefix + "/getPersonList?id=" + [[${id}]],
            exportUrl: prefix + "/export",
            modalName: "人员信息",
            columns: [{
                checkbox: true
            },
                {
                    field: 'name',
                    title: '姓名',
                    formatter: function(value, row, index) {
                        if(row.jobGradename == '中层' || row.jobGradename == '高层' ){
                            return '<span style=" color: red">' + value + '</span>';
                        }else{
                            return value;
                        }
                    }
                },
                {
                    field: 'badge',
                    title: '工号',
                },
                {
                    field: 'compname',
                    title: '所在公司',
                },
                {
                    field: 'departname',
                    title: '所在部门',
                },
                {
                    field: 'jobname',
                    title: '所在岗位',
                },
                {
                    field: 'reportToname',
                    title: '上级领导',
                },
                {
                    field: 'jobGradename',
                    title: '岗位级别',
                },
                {
                    field: 'empStatus',
                    title: '在岗状态',
                }]
        };
        $.table.init(options);
    }


    function details(){
        var row = $("#emp-table").bootstrapTable('getSelections');
        var num = 0;
        var allEid = "";
        if (row.length == 0) {
            $.modal.alertWarning("请选择需要调岗的人员");
            return;
        }

        for (var i = 0; i < row.length; i++) {
            $.operate.detail_currency(row[i].eid, row[i].name, "/neworgs/detail","da");
        }


    }
</script>
</body>
</html>